﻿@page
@using Sorry.NET.Models
@model IndexModel
@{
    ViewData["Title"] = "Gif 產生";
    List<TemplateModel> templates = ViewBag.Templates;
    IEnumerable<string> last5Image = ViewBag.Last5Image;
}

@if (last5Image != null && last5Image.Any())
{
    bool isFirst = true;

    <div id="Carousel" class="carousel slide" data-ride="carousel">
        <!-- Wrapper for slides -->
        <div class="carousel-inner">
            @foreach (var item in last5Image)
            {
                string className = (isFirst) ? "item active" : "item";

                <div class="@(className)">
                    <img src="@(item)" style="max-width:100%;margin: 0 auto;">
                </div>

                isFirst = false;
            }
        </div>
        <!-- Left and right controls -->
        <a class="left carousel-control" href="#Carousel" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#Carousel" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>

}
@foreach (var item in templates)
{
    using (Html.BeginForm())
    {
        @Html.ValidationSummary(true)
        @Html.AntiForgeryToken()

        <input type="hidden" name="Name" value="@(item.Name)">

        <div class="form-horizontal">
            <h4>@(item.Name)</h4>
            <hr />
            <div class="form-group">
                <div class="col-md-6">
                    <img src="@(item.DemoGif)" />
                </div>
                <div class="col-md-6">
                    @for (int i = 0; i < item.Sentences.Length; i++)
                    {
                        <input type="text" class="form-control" name="@(string.Format("Sentences[{0}]",i))" placeholder="@(item.Sentences[i])" />
                    }
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-offset-6 col-md-6">
                    <input type="submit" value="產生 Gif" class="btn btn-primary" />
                    <input type="reset" value="重設" class="btn btn-default" />
                </div>
            </div>
        </div>
    }
}
